﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <title>老师管理</title>
    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="/JqueryPlug/zTree_v3/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" />
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.css?v=4.3.0" rel="stylesheet"> 
    <link href="/CSS/V3/animate.css" rel="stylesheet">
    <link href="/CSS/V3/style.css?v=2.2.0" rel="stylesheet">
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script> 
    <script src="/JqueryPlug/laypage/laypage.js"></script>
    <script src="/Scripts/avalon.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
    <script src="/JqueryPlug/zTree_v3/js/jquery.ztree.excheck-3.5.min.js"></script>
    <script>
        var zNodes = null;
        var zTreeObj = null;
        var model = avalon.define({
            $id: "LSGL",
            menutype: "-1",//菜单类型(0:我的客户.-1:"当前部门客户")
            queryuser: ComFunJS.getnowuser(),
            username: ComFunJS.getnowuser(),
            fnqueryuser: function (item) {
                if (item) {
                    model.queryuser = item;
                    model.CommonData.clear();
                    model.GetLSData();
                }
            },
            XMType: "0",
            XMContent: "",
            peo:"",
            selXMType: "0",
            selXMContent: "",
            selpeo:"",
            CommonData: [],
            ViewDT: function (id) {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=LSGL&ID=" + id + "&pageType=view&r=" + Math.random(), "添加数据", "1000", "");
            },
            LSGLADD: function () {
                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=LSGL", "添加数据", "1000", "");
            },
            GetLSData: function () {
                $.getJSON('/API/FTAPI.ashx?Action=GETLSGLLIST', { P1: model.XMType, p: 1, P2: model.peo, Content: model.XMContent, b: model.menutype,  QUSER:  model.queryuser}, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.CommonData.clear();
                        model.CommonData = resultData.Result;
                        model.selXMType = model.XMType;
                        model.selpeo = model.peo;
                        model.selXMContent = model.XMContent;
                        if (parseInt(resultData.Result1) > 0) {
                            $("#pageDiv").show();
                            laypage({
                                cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                                pages: parseInt(resultData.Result1), //通过后台拿到的总页数
                                curr: 1, //初始化当前页
                                jump: function (e) { //触发分页后的回调
                                    if (model.selXMType != model.XMType || model.selXMContent != model.XMContent) {
                                        e.curr = 1;
                                    }
                                    $.getJSON('/API/FTAPI.ashx?Action=GETLSGLLIST', { P1: model.XMType, p: e.curr, P2: model.peo, Content: model.XMContent, b: model.menutype,  QUSER:   model.queryuser  }, function (resultData) {
                                        model.CommonData.clear();
                                        model.CommonData = resultData.Result;
                                        model.selXMType = model.XMType;
                                        model.selXMContent = model.XMContent;
                                        model.selpeo = model.peo;
                                    })
                                }
                            });
                        }
                        else {
                            $("#pageDiv").hide();
                        }
                    }
                })
            },
            EditLSGL: function (Id) {

                parent.ComFunJS.winviewform("/View/APPBaseView/APP_ADD_WF.html?FormCode=LSGL&ID=" + Id+"&r="+Math.random(), "添加数据", "1000", "");
            },
            DelLSGL: function (scel) {

                parent.ComFunJS.winconfirm("确认要删除么", function () {

                    $.post("/API/FTAPI.ashx", { Action: "DELLSGLBYID", P1: scel.ID }, function (result) {
                        var jsonresult = $.parseJSON(result)
                        if ($.trim(jsonresult.ErrorMsg) != "") {
                            parent.ComFunJS.winwarning(jsonresult.ErrorMsg);
                        } else {
                            model.CommonData.remove(scel);
                        }
                    })
                }, function () { })
            },
            LB: function () {
                model.XMType = $(this).attr("val");
                if ($(this).hasClass("btn-primary")) {
                    model.GetLSData()
                }
                else {
                    $(".leibie").removeClass("btn-primary");
                    $(".leibie").addClass("btn-white");
                    $(this).removeClass("btn-white");
                    $(this).addClass("btn-primary");
                    model.GetLSData()
                }
            },
            IsShowTR: false,
            getMenu: function () {
                var setting = {
                    data: {
                        simpleData: {
                            enable: true,
                            idKey: "id",
                            pIdKey: "pId",
                            rootPId: 0
                        }
                    },
                    view: {
                        showLine: false
                    },
                    callback: {
                        onClick: model.zTreeOnClick
                    }
                };
                $.ajax({
                    type: "GET",
                    url: "/API/SZHLAPI.ashx",
                    dataType: "html",
                    data: { "Action": "GETALLBMUSERLIST" },
                    success: function (msg) {
                        if (JSON.parse(msg).Result)
                        {
                            model.IsShowTR = true;
                        }
                        zTreeObj = $.fn.zTree.init($("#tree"), setting, eval(JSON.parse(msg).Result));
                    }
                });
            },
            zTreeOnClick: function (event, treeId, treeNode) {
                model.queryuser = "";
                model.CommonData.clear();
                if (treeNode.isUser) {
                    model.queryuser = treeNode.id;
                } else { 
                    model.menutype = treeNode.id;
                    if (treeNode.children.length > 0 && treeNode.children[0].isUser) {

                        $(treeNode.children).each(function (i, user) {
                            model.queryuser += user.id + ",";
                        })
                        model.queryuser = model.queryuser.substring(0, model.queryuser.length - 1); 
                    } 
                }
                model.GetLSData();
            },
            SS: function () {
                model.peo = $(this).attr("val");
                if ($(this).hasClass("btn-primary")) {
                    model.GetLSData()
                }
                else {
                    $(".suoshu").removeClass("btn-primary");
                    $(".suoshu").addClass("btn-white");
                    $(this).removeClass("btn-white");
                    $(this).addClass("btn-primary");
                    model.GetLSData()
                }
            }
        });
        avalon.ready(function () {
            ComFunJS.initsetajax();
            model.GetLSData();
            model.getMenu();
        })

    </script>

</head>
<body class="gray-bg" ms-controller="LSGL">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-3">
                <div class="ibox float-e-margins">
                    <div class="ibox-content" style="border: 0; border-right: 1px solid #e7eaec;">
                        <div class="file-manager">
                            <div class="hr-line-dashed"></div>
                            <button class="btn btn-primary btn-block" ms-click="LSGLADD()">添加老师</button>
                            <div class="hr-line-dashed"></div>
                            <div class="clearfix"></div>
                            <h4 class="tag-title">老师创建人</h4>
                            <ul id="tree" ms-if="model.IsShowTR" class="ztree"></ul>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-9">
                <div class="ibox">
                    <div class="box" style="margin-bottom:15px;">

                        <div class="pull-right mail-search">
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" ms-duplex="XMContent" name="search" placeholder="输入老师名称查询">
                                <div class="input-group-btn">
                                    <button type="submit" class="btn btn-sm btn-primary" ms-click="GetLSData()">
                                        搜索
                                    </button>
                                </div>
                            </div>
                        </div>
                        <h2>
                           老师管理
                        </h2>
                        <div class="mail-tools tooltip-demo m-t-md">

                            <div class="btn-group pull-right">
                                <div id="pageDiv" class="text-center"></div>
                            </div>
                         
                        </div>

                    </div>

                </div>
                <div class="full-height-scroll" style="margin-top:80px">
                    <div class="table-responsive">
                        <table class="table  table-hover">
                            <thead>
                                <tr>

                                    <th>老师类别</th>
                                    <th>老师名称</th>
                                    <th >老师联系方式</th>
                                    <th>主要课程</th>
                                    <th>创建人</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ms-repeat-el="CommonData">
                                    <td>
                                        {{el.LS_Type}}
                                    </td>
                                    <td>
                                        {{el.LS_LSXM}}
                                    </td>
                                    <td>{{el.LS_LSLXFS}}</td>
                                    <td>{{el.LS_ZYKC}}</td>
                                    <td> {{ComFunJS.convertuser(el.CRUser)}}</td>
                                    <td class="client-status">
                                        <a class=" btn btn-white btn-xs" ms-click="ViewDT(el.ID)"><i class="fa fa-search"></i> 查看 </a>
                                        <a class=" btn btn-primary btn-xs" ms-click="EditLSGL(el.ID)" ms-if="el.CRUser==username"><i class=" fa fa-pencil"></i> 编辑 </a>
                                        <a class="btn btn-danger btn-xs" ms-click="DelLSGL(el)" ms-if="el.CRUser==username"><i class="fa fa-trash-o"></i> 删除 </a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

